home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / endo / vueinit.c < prev    next >
C/C++ Source or Header  |  1995-05-03  |  4KB  |  102 lines

  1. /*************************************************************************
  2.  *                                                                       *
  3.  *  Copyright (c) 1992, 1993 Ronald Joe Record                           *
  4.  *                                                                       *
  5.  *  All rights reserved. No part of this program or publication may be   *
  6.  *  reproduced, transmitted, transcribed, stored in a retrieval system,  *
  7.  *  or translated into any language or computer language, in any form or *
  8.  *  by any means, electronic, mechanical, magnetic, optical, chemical,   *
  9.  *  biological, or otherwise, without the prior written permission of:   *
  10.  *                                                                       *
  11.  *      Ronald Joe Record (408) 458-3718                                 *
  12.  *      212 Owen St., Santa Cruz, California 95062 USA                   *
  13.  *                                                                       *
  14.  *************************************************************************/
  15.  
  16. /*************************************************************************
  17.  *                                                                       *
  18.  *     Copyright (c) 1989                  Hiram Clawson                 *
  19.  *                                                                       *
  20.  *  All rights reserved. No part of this program or publication may be   *
  21.  *  reproduced, transmitted, transcribed, stored in a retrieval system,  *
  22.  *  or translated into any language or computer language, in any form or *
  23.  *  by any means, electronic, mechanical, magnetic, optical, chemical,   *
  24.  *  biological, or otherwise, without the prior written permission of:   *
  25.  *                                                                       *
  26.  *              Hiram Clawson                        (408) 429-5647      *
  27.  *              P. O. Box 3178, Santa Cruz, California 95063-3178 USA    *
  28.  *                                                                       *
  29.  *************************************************************************/
  30. /*************************************************************************
  31.  *        vueinit.c: Initialize the 3D viewing window                    *
  32.  *                                                                       *
  33.  *                Written by Hiram Clawson.                              *
  34.  *                Ported to X11 by Ronald Joe Record.                    *
  35.  *************************************************************************/
  36.  
  37. #define __MAIN__
  38. #include "globals.h"
  39. #undef __MAIN__
  40.  
  41. void 
  42. vue_init( wc, win_wide, win_high )
  43. triple wc;
  44. int win_wide, win_high;
  45. {
  46.     static double length_center_upper_right;
  47.     static double window_half_height;
  48.     extern void view_point_constants();
  49.  
  50.     screen_max.x = win_wide;
  51.     screen_max.y = win_high;
  52.     screen_center.x = win_wide >> 1;
  53.     screen_center.y = win_high >> 1;
  54.  
  55.     window_center.x = wc.x; window_center.y = wc.y; window_center.z = wc.z;
  56.     window_half_height = sqrt((wc.x * wc.x) +
  57.                   (wc.y * wc.y) +
  58.                   (wc.z * wc.z)) / 2.0;
  59.  
  60.     /* establish initial viewing window in 3D space */
  61.     /* the initial window is parallel to the X-Y plane */
  62.     /* and window_origin_distance units from the origin */
  63.  
  64.     /* NOTE: window units are whatever 3D space units are */
  65.  
  66. /* the top of the window is window_half_height units high on the Y axis */
  67.  
  68.     window_top.x = wc.x;
  69.     window_top.y = wc.y + window_half_height;
  70.     window_top.z = wc.z;
  71.  
  72.     window_right.x = window_top.y;
  73.     window_right.y = wc.y;
  74.     window_right.z = wc.z;
  75.  
  76.     /* the window upper right is determined by the top and right sides */
  77.  
  78.     window_upper_right.x = window_right.x;
  79.     window_upper_right.y = window_top.y;
  80.     window_upper_right.z = wc.z;
  81.  
  82.     /* compute distance from center to upper right */
  83.  
  84.     length_center_upper_right = sqrt(
  85.         ((window_upper_right.x - wc.x)*(window_upper_right.x - wc.x)) +
  86.         ((window_upper_right.z - wc.z)*(window_upper_right.z - wc.z)) +
  87.         ((window_upper_right.y - wc.y)*(window_upper_right.y - wc.y)));
  88.  
  89.     /* and the view point is further along the positive Z axis */
  90.     /* by an amount to make the angle (center - view - upper right) be */
  91.     /* 30 degrees so that the initial field of view will be 60 degrees */
  92.  
  93.     view_point.x = window_center.x;
  94.     view_point.y = window_center.y;
  95.     view_point.z = window_center.z + (length_center_upper_right /
  96.                             TAN_30_DEGREES);
  97.  
  98.     view_point_constants();
  99.     return;
  100.  
  101. }    /* end of view_init */
  102.